import { Controller, Get, Post, Param, Body, Req } from '@nestjs/common';
import { QiniuService } from '../services/qiniu.service';

@Controller('/qiniu')
export class QiniuController {
    constructor(private readonly qiniuService: QiniuService) {}

    @Get('/token')
    qiniuToken() {
        return {
            token: this.qiniuService.genToken(),
            cdn: this.qiniuService.qiniuConfig.cdn_url,
        };
    }

    @Post('/upload')
    url2QiniuFile(@Body('url') url: string) {
        return this.qiniuService.qiniuUploadHttpFile(url);
    }
}
